package com.yanqu.road.entity.autodata.chuhan.config;

import com.yanqu.road.entity.FieldTypeAnnotation;
import com.yanqu.road.entity.autodata.AutoActivityConfigObject;
import com.yanqu.road.utils.date.DateHelper;
import com.yanqu.road.utils.string.StringUtils;

import java.util.ArrayList;
import java.util.List;

@FieldTypeAnnotation(tableName = "t_s_activity_chuhan_buff_type")
public class ChuHanBuffTypeConfig extends AutoActivityConfigObject {

    @FieldTypeAnnotation(desc = "活动ID", select = true)
    private int activityId;
    @FieldTypeAnnotation(desc = "id")
    private int id;
    @FieldTypeAnnotation(desc = "buff类型")
    private int type;
    @FieldTypeAnnotation(desc = "buff图标")
    private int icon;
    @FieldTypeAnnotation(desc = "buff名称")
    private String name;
    @FieldTypeAnnotation(desc = "buff详情")
    private String desc;
    @FieldTypeAnnotation(desc = "buff效果")
    private String buffEffect;
    @FieldTypeAnnotation(desc = "持续时间/h")
    private int continueTime;

    private List<List<Integer>> buffParams = new ArrayList<>();

    public ChuHanBuffTypeConfig() {
    }

    public int getActivityId() {
        return activityId;
    }

    public void setActivityId(int activityId) {
        this.activityId = activityId;
    }

    public int getId() {
        return id;
    }

    public void setId(int id) {
        this.id = id;
    }

    public int getType() {
        return type;
    }

    public void setType(int type) {
        this.type = type;
    }

    public int getIcon() {
        return icon;
    }

    public void setIcon(int icon) {
        this.icon = icon;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public String getDesc() {
        return desc;
    }

    public void setDesc(String desc) {
        this.desc = desc;
    }

    public String getBuffEffect() {
        return buffEffect;
    }

    public void setBuffEffect(String buffEffect) {
        this.buffEffect = buffEffect;

        //按|隔开,再按;隔开
        List<List<Integer>> tempList = new ArrayList<>();
        for (String s : buffEffect.split("\\|")) {
            List<Integer> list = StringUtils.stringToIntegerList(s, ";");
            tempList.add(list);
        }
        this.buffParams = tempList;
    }

    public int getContinueTime() {
        return continueTime;
    }

    public void setContinueTime(int continueTime) {
        this.continueTime = continueTime;
    }

    public long getContinueMillis() {
        return continueTime * DateHelper.HOUR_MILLIONS;
    }

    public List<List<Integer>> getBuffParams() {
        return buffParams;
    }

    public List<Integer> getBuffParamsByLevel(int level) {
        if (buffParams.size() == 0) {
            return new ArrayList<>();
        }
        if (level <= buffParams.size() && level > 0) {
            return buffParams.get(level - 1);
        } else {//超过等级配置取最后一条
            return buffParams.get(buffParams.size() - 1);
        }
    }
}
